<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            height: 500px;
            width: 500px;
            background-color: pink;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            /* 盒子宽度的一般,和高度的一半 */
        }
        .box2{
            position: relative;
            height: 200px;
            width: 300px;
            background-color:yellow;
        }
        .box3{
            position: absolute;
            height: 50px;
            width: 50px;
            background-color: red;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

    </style>
</head>
<body>
    <div class="box">
    </div>
    <div class="box2">
        <div class="box3"></div>
    </div>
</body>
</html>